package tablero;
import java.util.ArrayList;
import java.util.List;

import modelo.Player;



public class Square implements Comparable<Square>{

	private int squareNum;
	private String squareName;
    private List<Player> playerList;
    
    public Square(int numCasilla,String nombreCasilla){
    	this.squareNum=numCasilla;
    	this.squareName=nombreCasilla;
    	playerList=new ArrayList<Player>();
    }
    
    public Square(){
    	playerList=new ArrayList<Player>();
    }
    
    public List<Player> getPlayerList(){
    	return playerList;
    }

	public int getNumCasilla() {
		return squareNum;
	}

	public void setSquareNumber(int numCasilla) {
		this.squareNum = numCasilla;
	}

	public String getSquareName() {
		return squareName;
	}

	public void setSquareName(String nombreCasilla) {
		this.squareName = nombreCasilla;
	}
	
	public boolean addPlayer(Player player){
		if(playerList.add(player))return true;
		else return false;
	}
	
	public boolean removePlayer(Player player){
		if(playerList.remove(player))return true;
		else return false;
	}
	

	
	@Override
	public String toString() {
		return  squareNum+".-"+ squareName +", jugadores aqui: "+playersHere();
	}

	public String playersHere(){
		String jugadores="";
		if(this.playerList.size()==0){
			jugadores="vacio";
		}
		else{
			for(Player j:playerList) jugadores=jugadores+j.getNombreJugador()+" ";
		}
		return jugadores;
	}

	@Override
	public int compareTo(Square o) {
		// TODO Auto-generated method stub
		return (this.squareNum-o.squareNum);
	}
    
}
